
package com.example.s09thymeleaf.entity;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.hibernate.validator.constraints.Range;
import org.springframework.format.annotation.DateTimeFormat;
import javax.validation.constraints.Email;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.Past;
import javax.validation.constraints.Pattern;
import java.util.Date;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class Teacher {
    @NotEmpty(message = "姓名不能为空")
    private String name;
    @Range(min = 1,max = 120,message = "年龄介于1-120之间")
    private int age;
    @Email(message = "邮箱地址不符合邮箱的格式")
    private String email;
    @Pattern(regexp = "^(?![0-9]+$)(?![a-zA-Z]+$)[0-9A-Za-z]{6,16}$",message = "密码必须由数字字母组成，长度为6-16")
    private String password;
    @Past(message = "出生日期必须是过去的时间")
    @DateTimeFormat(pattern="yyyy-MM-dd")
    private Date birthday;
}
